package com.xpmusic.util;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class ServletUtil {
    /**
     * 获取发送的流数据
     * @param request
     * @return
     * @throws IOException
     */
    public static String getInputStringInfo(HttpServletRequest request) throws IOException {
        InputStream inputStream = request.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
        String string = "";
        StringBuffer stringBuffer = new StringBuffer();
        while ((string = bufferedReader.readLine()) != null){
            stringBuffer.append(string);
        }
        return stringBuffer.toString();
    }
}
